﻿Namespace DotNetNuke.Modules.ActiveForums
    Public Class UsersOnline
        Public Function GetUsersOnline(ByVal PortalId As Integer, ByVal ModuleId As Integer, ByVal UserId As Integer) As String

            Dim sb As New Text.StringBuilder
            Dim dr As IDataReader = DataProvider.Instance.Profiles_GetUsersOnline(PortalId, ModuleId, 2)
            Try
                Dim MainSettings As SettingsInfo = DataCache.MainSettings(ModuleId)
                While dr.Read
                    Dim ai As New Author
                    With ai
                        .AuthorId = CInt(dr("UserId"))
                        .DisplayName = dr("DisplayName").ToString
                        .Email = dr("Email").ToString
                        .FirstName = dr("FirstName").ToString
                        .LastName = dr("LastName").ToString
                        .Username = dr("Username").ToString
                    End With
                    sb.Append(UserProfiles.GetDisplayName(ModuleId, MainSettings.MemberListMode, False, ai.AuthorId, MainSettings.UserNameDisplay, ai))
                    sb.Append(", ")

                End While
                If sb.Length > 3 Then
                    sb.Remove(sb.Length - 2, 2)
                End If
                dr.Close()
                Return sb.ToString
            Catch ex As Exception
                If Not dr.IsClosed Then
                    dr.Close()
                End If
                Return String.Empty
            End Try


        End Function

    End Class
End Namespace
